Neurosis Engine
io_misc.h
Go to the documentation of this file.
00001 
00002 // Neurosis Engine - LP23.com
00003 // Copyright © Luigi Pino. All rights reserved.
00004 
00005 /***************************************************************************/
00006 
00007 #ifndef _NEUROSIS_ENGINE_IO_MISC_H_
00008 #define _NEUROSIS_ENGINE_IO_MISC_H_
00009 
00010 /***************************************************************************/
00011 
00012 //------------------------------------------------
00013 #define NOTHING_PRESSED           0
00014 #define BUTTON_1                  1
00015 #define BUTTON_2                  2
00016 #define BUTTON_3                  4
00017 #define BUTTON_4                  8
00018 #define BUTTON_5                  16
00019 #define BUTTON_6                  32
00020 #define BUTTON_7                  64
00021 #define BUTTON_8                  128
00022 #define BUTTON_9                  256
00023 //------------------------------------------------
00024 #define UP                        0
00025 #define DOWN                      1
00026 #define LEFT                      2
00027 #define RIGHT                     3
00028 //------------------------------------------------
00029 #define MOUSE                     0
00030 #define KEYBOARD_1                1
00031 #define KEYBOARD_2                2
00032 #define JOYSTICK_1                3
00033 #define JOYSTICK_2                4
00034 #define JOYSTICK_3                5
00035 #define JOYSTICK_4                6
00036 #define COMPUTER                  7
00037 #define NO_USER                   8
00038 //------------------------------------------------
00039 
00040 /***************************************************************************/
00041 
00042 class CNeurosisController {
00043   private:
00044     class CJoystick {
00045       public:
00046         CJoystick();
00048         ~CJoystick();
00049 
00051         MMRESULT Get_Joystick_Name(UINT id, TCHAR * pszName);
00052 
00053         int       mAxis4;                             // Forth axis
00054         int       mAxis5;                             // Fifth axis
00055         int       mAxis6;                             // Sixth axis
00056         int       mPOV;                               // Point of view
00057         JOYINFOEX info;                               // Info tag
00058       };
00059 
00060     class CKeyboard {
00061       public:
00062         CKeyboard();
00064         ~CKeyboard();
00065 
00067         void Set_Keys(int b0, int b1, int b2, int b3, int b4, int b5, int b6, int b7, int b8, int up, int down, int left, int right);
00068 
00069         int mButtonID[9];                             // Button ID
00070         int mDirectionID[4];                          // Direction ID
00071       };
00072 
00073     class CMouse {
00074       public:
00075         CMouse();
00077         ~CMouse();
00078 
00079         float3  mChange;                              // Change in position
00080         POINT   mCurrent;                             // New position
00081         POINT   mPrevious;                            // Old position
00082       };
00083 
00084   public:
00085     CNeurosisController(int iType = MOUSE);
00087     ~CNeurosisController();
00088 
00090     void  Clear();
00092     bool  Interval(float2 *key, float interval);
00094     void  Update(float timeStep, bool mouseBoundsReset);
00095 
00096     CJoystick       mJoystick;                        // Joystick input
00097     CKeyboard       mKeyboard;                        // Keyboard input
00098     CMouse          mMouse;                           // Mouse input
00099     float2          mButton[9];                       // \  Amount pressed: x (current interval)
00100     float2          mDirection[4];                    // /                  y (total interval)
00101     int             mType;                            // Mouse, Keyboard, Joystick, Computer or None
00102 };
00103 
00104 /***************************************************************************/
00105 
00106 class CNeurosisTiming {
00107   public:
00108     CNeurosisTiming();
00110     ~CNeurosisTiming();
00111 
00113     float Get_Processor_Speed();
00115     float Get_Time_Step();
00117     void  Set_Time_Step(float amount);
00119     void  Update();
00120 
00121   private:
00122     void      Calculate_Frequency();
00123     unsigned  Get_CPU_Cycle();
00124 
00125     bool      mPrecision;                             // Which timing function to use
00126     float     mProcessorSpeed;                        // MHz of computer
00127     float     mTimeStep;                              // Time between cycle calls (1/x = FPS)
00128     unsigned  mCycleBegin;                            // Start of cycle call
00129     unsigned  mCycleEnd;                              // End of cycle call
00130 };
00131 
00132 /***************************************************************************/
00133 #endif